<?php
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$id = $_GPC['id'];
$op = $_GPC['op'];
$cate_id = $_GPC['cate_id'];
$setting = $this->baseset($_W['uniacid']);
if ($cate_id) {
	$condition .= " AND CONCAT(`cate_id`) = '{$cate_id}' AND status=1";
} else {
	$condition .= " AND status=1";
}
$uniacid = $_W['uniacid'];
if ($op == 'list' || empty($op)) {
	if ($_W['ispost'] && $op == 'list') {
		$nowpage = $_GPC['limit'];
		$pindex = max(1, intval($nowpage));
		if ($setting['pageno']) {
			$psize = $setting['pageno'];
		} else {
			$psize = 10;
		}
		$list = pdo_fetchall("SELECT * FROM " . tablename($this->tableitemdtk) . " WHERE uniacid = '{$_W['uniacid']}' $condition order by displayorder desc,id desc LIMIT " . ($pindex - 1) * $psize . ',' . $psize);
		if (!empty($keyword) && empty($list)) {
			exit(json_encode(array('status' => 301, 'content' => $list)));
		}
		if (!empty($list)) {
			foreach ($list as $key => $value) {
				$list[$key]['jiage'] = $list[$key]['itemfee2'];
				$list[$key]['jiage2'] = $list[$key]['itemfee'] - $list[$key]['itemfee2'];
				$list[$key]['tag'] = $list[$key]['itemyhj_tit'];
				$list[$key]['itemyhj_tit'] = explode('，', $list[$key]['itemyhj_tit']);
				$list[$key]['toptag'] = $list[$key]['itemyhj_tit'][0];
				if (time() - strtotime($list[$key]['itemyhj_etime']) >= 86400) {
					$list[$key]['toptag'] = '抢购';
					$list[$key]['tag'] = '抢购';
					$list[$key]['jiage'] = $list[$key]['itemfee2'];
				}
				if ($list[$key]['istmall'] == 1) {
					$list[$key]['icon'] = tomedia("../addons/bsht_tbk/res/images/tmall.png");
				} else {
					$list[$key]['icon'] = tomedia("../addons/bsht_tbk/res/images/taobao.png");
				}
				$list[$key]['pic'] = tomedia($list[$key]['itempic']);
				$list[$key]['url'] = $this->createMobileUrl('show_dtk', array('id' => $list[$key]['id'], 'op' => 'share'));
				$list[$key]['yhjurl'] = $this->createMobileUrl('show_dtk', array('id' => $list[$key]['id'], 'op' => 'yhj'));
			}
			$sta = 200;
		} else {
			$sta = -103;
		}
		exit(json_encode(array('status' => $sta, 'content' => $list)));
	}
}